﻿
<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>系统参数</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/X-admin/lib/layui/layui.js"></script>
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
    <script type="text/html" id="barDemo">
        <a title="编辑" href="javascript:;" lay-event="edit" id="frmEdit"><i class="layui-icon">&#xe642;</i></a>
        <a title="删除" href="javascript:;" lay-event="del" id="frmDel"><i class="layui-icon">&#xe640;</i></a>
    </script>

</head>
<body>
    <div class="layui-fluid">
        <div id="bDiv">
        </div>
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="parCode" placeholder="参数编码" autocomplete="off" class="layui-input" id="parCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="parName" placeholder="参数名称" autocomplete="off" class="layui-input" id="parName">
                            </div>

                            <div class="layui-inline layui-show-xs-block">

                                <select id="partype" class="tClass" name="partype" autocomplete="off">
                                    <option value="">参数类型</option>
                                </select>
                            </div>
                     
                        </form>
                    </div>
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    var menuCode="";
    $(function () {
        menuCode = getUrlVariable("menuCode");
        BannerData(menuCode, "bDiv");
        DictionaryDropDown("sp", "partype", "");
        loadData();
        $(document).keyup(function (event) {
            if (event.keyCode == 13) {
                loadData();
            }
        })
    })
    //赋值用户列表
    function loadData() {
        layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
                , cols: [[ //标题栏
                    { field: 'partypeName', title: '参数类型', width: 100, fixed: 'left' }
                    , { field: 'parCode', title: '参数编码', width: 120, sort: true }
                    , { field: 'parName', title: '参数名称', width: 180 }
                    , { field: 'parValue', title: '参数值', width: 250}
                    , { field: 'createtime', title: '创建时间', width: 170 }
                    , { field: 'memo', title: '备注说明', width: 250 }
                    , { field: 'enableName', title: '参数状态', width: 90 }

                    , { field: 'right', title: '数据操作', toolbar: '#barDemo', width: 90, fixed: 'right' }
                ]], done: function (res, curr, count) {
                    TablePowerHide();
                }
                // , height: $(document).height() - $('#list').offset().top - 20
                , url: '../System/getDataList?condition=' + conditon + "&dataType=par" //数据接口
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [15, 25, 40]
                , limit: 15 //每页默认显示的数量
            });

            //监听行工具事件
            table.on('tool(list)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值

                if (layEvent == 'edit') {
                    InfoOpenPage('../System/UpdateParameter?dataId=' + data.parCode, data.parName + "-修改", "85%", "80%", true);
                } else if (layEvent == 'del') {
                    layer.confirm('确认要删除该数据？', function (index) {
                        var info = DelData(data.parCode);
                        if (info.result) {
                            obj.del();
                        } else {
                            layer.msg(info.message);
                        }
                        layer.close(index);
                    });

                }
            });
        });
    }

    function openWin() {
        InfoOpenPage("../System/UpdateParameter?dataId=0", "系统参数添加", "85%", "80%",true);
    }
    /**
    删除方法
    **/
    function DelData(dataId) {
        var info = undefined;
        $.ajax({
            url: "../System/DelParmeter",
            data: { parCode: dataId },
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {
                info = data;
            }
        });
        return info;
    }

</script>